package com.liuyanban.dao.impl.user;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.liuyanban.dao.user.LoginDao;
import com.liuyanban.domain.user.User;

@Repository("loginDao")
public class LoginDaoImpl implements LoginDao {

	@Resource(name = "hibernateTemplate")
	private HibernateTemplate hibernateTemplate;

	@Override
	public User authentication(String username, String password) {
		List<User> users = this.hibernateTemplate.find(
				"from User where username = ? and userpassword = ?", username,
				password);
		if (users.size() == 0) {
			return null;
		} else {
			return users.get(0);
		}
	}
}
